import Ember from 'ember';
import BaseBusiness from '../base-business';
export default BaseBusiness.extend({
header_title:'个人信息',
  model(){
    console.log("csinfo model");
    var model = Ember.Object.create({});
    return model;
  },
  setupController: function(controller,model){
    this._super(controller,model);
    console.log("mode in setupController",model);
    var curUser = this.get("global_curStatus").getUser();//拿到数据
    var _self = this;


    _self.store.query("account",{filter:{user:{id:curUser.get("id")}}}).then(function(accounts){
      model.set("accountUser",accounts.get("firstObject"));
    });
    _self.store.findRecord("userPrivate",curUser.get("id")).then(function(userEnt){
      model.set("curUser",userEnt);
      _self.store.query("dicttype",{filter:{typegroup:{typegroupcode:'tasktype'},'remark@$or1---1':1,'remark@$or1---2':2}}).then(function(cstags) {
        model.set("cstag",cstags);
        if(model.get("curUser.cstag")){
          model.get("curUser.cstag").forEach(function(lan){
            lan.set('checked',true);
          });
        }
      });
      _self.store.query("dicttype",{filter:{typegroup:{typegroupcode:'csLanguage'}}}).then(function(lists) {
        model.set("language",lists);
        if(model.get("curUser.language")){
          model.get("curUser.language").forEach(function(lan){
            lan.set('checked',true);
          });
        }
      });
    });
    controller.set("errorText",null);
    controller.set("errorText1",null);
    controller.set("errorText2",null);
  },
  actions:{
    checkout(){
      var curController = this.getCurrentController();
      if( curController.get('model.curUser').get('status') === 2) {
        return  ;
      }else {
        if(curController.get('model.curUser').get('status') === 3){
          curController.set('isDisabled',false);
          curController.model.curUser.set("isCheckin",true);
        }else {
          curController.set("isDisabled",false);
          curController.set("isDisabled3",false);
          curController.model.curUser.set("isCheckin",true);
        }
      }
    },//修改
    cancel(){
      var curController = this.getCurrentController();
      curController.set("isDisabled",true);
      curController.set("isDisabled3",true);
      curController.get('model.curUser').set("isCheckin",false);
      curController.set('name',curController.get('model.curUser').get('name'));
      curController.set('address',curController.get('model.curUser').get('address'));
      curController.set('phone',curController.get('model.curUser').get('phone'));
      curController.set('qqnum',curController.get('model.curUser').get('qqnum'));
      curController.set('weixin',curController.get('model.curUser').get('weixin'));
      curController.set('email',curController.get('model.curUser').get('email'));
      curController.set('desc',curController.get('model.curUser').get('desc'));
      curController.set('age',curController.get('model.curUser').get('age'));
      curController.set('sexStr',curController.get('model.curUser').get('sexStr'));
      curController.set('introduce',curController.get('model.curUser').get('introduce'));
      curController.set('idcardNum',curController.get('model.curUser.edinfo').get('idcardNum'));
      curController.set('zhifubao',curController.get('model.accountUser').get('zhifubao'));
      curController.set('cardNumber',curController.get('model.accountUser').get('cardNumber'));
    },//‘取消’按钮
  }
});
